import building
import ctypes
import game
import map
import math
import pyglet
from pyglet.gl import *
import random
import thing
import time
import unit
import vector


fourfv = ctypes.c_float * 4


class Window(pyglet.window.Window):
	'''Window responsible for drawing the scene and receiving
	input from the player.
	'''

	def __init__(self):
		pyglet.window.Window.__init__(self, width=800, height=600, caption='Mechazoid')
		self.clear()
		self.flip()

		# graphics
		glEnable(GL_COLOR_MATERIAL)
		glEnable(GL_DEPTH_TEST)
		glEnable(GL_CULL_FACE)
		glDepthFunc(GL_LEQUAL)
		glEnable(GL_BLEND)
		glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
		glEnable(GL_LIGHTING)
		glEnable(GL_LIGHT0)
		glLightfv(GL_LIGHT0, GL_POSITION, fourfv(-100, 100, 100, 0))
		glLightfv(GL_LIGHT0, GL_AMBIENT, fourfv(.1, .1, .1, 3))
		glLightfv(GL_LIGHT0, GL_DIFFUSE, fourfv(1, 1, 1, 1))
		glLightfv(GL_LIGHT0, GL_SPECULAR, fourfv(1, 1, 1, 1))

		# mouse
		self.set_mouse_cursor(self.get_system_mouse_cursor(self.CURSOR_CROSSHAIR))

	def on_resize(self, width, height):
		glViewport(0, 0, width, height)
		glLoadIdentity()
		self.clear()

	def on_key_press(self, symbol, modifiers):
		if symbol == pyglet.window.key.ESCAPE:
			pyglet.app.exit()

